package com.qzimp.fujiancuo.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.qzimp.fujiancuo.entity.Event;
import com.qzimp.fujiancuo.entity.vo.ResultVo;
import com.qzimp.fujiancuo.mapper.EventMapper;
import com.qzimp.fujiancuo.service.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  服务层实现。
 *
 * @author 吴宗波
 * @since 2024-11-21
 */
@Service
public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements EventService {
    @Autowired
    private EventMapper eventMapper;
    @Override
    public int addEvent(Event event) {
        return eventMapper.insertEvent(event);
    }

    @Override
    public int insertEvent(Event event) {
        return eventMapper.insert(event);
    }

    @Override
    public ResultVo queryByCuoId(Integer id) {
        List<Event> events = eventMapper.queryByCuoId(id);
        if (events.size() == 0) {
            return new ResultVo(1, "请求成功", "没有查到数据", true);
        }
        return new ResultVo(1, "请求成功", events, true);
    }
}
